package com.threadLocal;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * @auther carter
 * create time    2018-06-20
 */
public class ThreadId {


    private static final ThreadLocal<AtomicInteger> threadId = ThreadLocal.withInitial(() -> new AtomicInteger(0));

    public static int get()
    {
        threadId.set(new AtomicInteger(threadId.get().incrementAndGet()));
        return threadId.get().get();
    }

}
